import { h } from 'vue';
import { Avatar, Tag, Tooltip, Image } from 'ant-design-vue';
import { useMessage } from '/@/hooks/web/useMessage';
import Icon from '/@/components/Icon';

const { createMessage } = useMessage();

enum Api {
    img="/activiti/models/export",
}

const activitiUtils = {
  //转换时分秒
  millsToTime:({text})=>{
    
      if (!text) {
        return "";
      }
      let s = text / 1000;
      if (s < 60) {
        return s.toFixed(0) + " 秒"
      }
      let m = s / 60;
      if (m < 60) {
        return m.toFixed(0) + " 分钟"
      }
      let h = m / 60;
      if (h < 24) {
        return h.toFixed(0) + " 小时"
      }
      let d = h / 24;
      if (d < 30) {
        return d.toFixed(0) + " 天"
      }
      let month = d / 30
      if (month < 12) {
        return month.toFixed(0) + " 个月"
      }
      let year = month / 12
      return year.toFixed(0) + " 年"
    },
    //图片
    showResource:({text})=>{
      let avatarList = text.split(',');
      return h(
        'span',
        avatarList.map((item) => {
          return h(Image, {
            src: `${window._CONFIG['domianURL']}${Api.img}?id=${item}`,
            width: 60,
            height: 60,
            style: { marginRight: '5px' },
            previewMask: () => {
              return h(Icon, { icon: 'ant-design:eye-outlined', size: 20 });
            },
          });
        })
      );
    },
}

export { activitiUtils };